﻿#include "MCUCodec_SetInterval_MEMSData.h"

#include "MCUCodec.h"
#include "TcpCodec.h"
#include "DataPackage_TcpCodec.h"

MCUCodec_SetInterval_MEMSData::MCUCodec_SetInterval_MEMSData()
{
  setObjectName(getClassNameFirstLow<MCUCodec_SetInterval_MEMSData>());
}

MCUCodec_SetInterval_MEMSData::~MCUCodec_SetInterval_MEMSData()
{

}

void MCUCodec_SetInterval_MEMSData::decode(QByteArray data)
{
  (void)data;
}

void MCUCodec_SetInterval_MEMSData::setInterval(uint deviceId, ushort interval)
{
  tcpCodec->code(TcpCodec::MCUCtl,QByteArray()
                                  .append((char*)&deviceId,4)
                                  .append(MCUCodec_SetInterval_MEMSData::SetInterval_MEMSData)
                                  .append((char*)&interval,2));
}

MCUCodec* MCUCodec_SetInterval_MEMSData::getMCUCodec()const
{
  return mCUCodec;
}

MCUCodec_SetInterval_MEMSData* MCUCodec_SetInterval_MEMSData::setMCUCodec(MCUCodec*const mCUCodec)
{
  this->mCUCodec=mCUCodec;
  mCUCodec->addToCodecMap(MCUCodec_SetInterval_MEMSData::SetInterval_MEMSData,this);
  printInjection(this,mCUCodec);
  return this;
}

TcpCodec* MCUCodec_SetInterval_MEMSData::getTcpCodec()const
{
  return tcpCodec;
}

MCUCodec_SetInterval_MEMSData* MCUCodec_SetInterval_MEMSData::setTcpCodec(TcpCodec* const tcpCodec)
{
  this->tcpCodec=tcpCodec;
  return this;
}

void MCUCodec_SetInterval_MEMSData::objectAutoInjection(QHash<QString,QObject*>* objMap)
{
  setMCUCodec(getObjFromMap<MCUCodec>(objMap));
  setTcpCodec(getObjFromMap<TcpCodec>(objMap));
}
